package cn.cnsuh.剑指offer.q53_中缺失的数字;

public class Main {
    public static void main(String[] args) {
        int[]arr = {0};
        System.out.println("missingNumber(arr) = " + missingNumber(arr));
    }

    static int missingNumber(int[] nums) {
        int l = 0, r = nums.length - 1;
        while (l <= r) {
            int mid = l + r >> 1;
            if (nums[mid] == mid) {
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        return l;
    }
}
